//
//  KDCollectCell.m
//  WangJingApp
//
//  Created by 魏强 on 17/11/6.
//  Copyright © 2017年 KDTech. All rights reserved.
//

#import "KDCollectCell.h"
#import "KDCollectCellModel.h"
@interface KDCollectCell ()
/**
 *  cell底部的view
 */
@property (weak, nonatomic) IBOutlet UIView *underView;
/**
 *  标题label
 */
@property (weak, nonatomic) IBOutlet UILabel *titleLb;
@property (weak, nonatomic) IBOutlet UILabel *comeFromLb;
@property (weak, nonatomic) IBOutlet UILabel *timeLb;
@property (weak, nonatomic) IBOutlet UILabel *authLb;

@property (weak, nonatomic) IBOutlet UIButton *moveBtn;
/**
 *  批示btn
 */
@property (weak, nonatomic) IBOutlet UIButton *reportBtn;
/**
 *  正反面属性btn
 */
@property (weak, nonatomic) IBOutlet UIButton *featureBtn;


/**  删除btn */
@property (weak, nonatomic) IBOutlet UIButton *deleteBtn;

@property (nonatomic, retain) NSDateFormatter *fmt;
@end
@implementation KDCollectCell
- (NSDateFormatter *)fmt
{
    if (!_fmt) {
        _fmt = [[NSDateFormatter alloc]init];
        _fmt.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];;
        _fmt.dateFormat = @"YYYY-MM-dd HH:mm:ss";
    }
    return _fmt;
}
+ (instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *cellId =@"KDCollectCell";
    
    
    KDCollectCell *cell =[tableView dequeueReusableCellWithIdentifier:cellId];
    cell.backgroundColor = BackGroundColor;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
//    cell.similarBtn.layer.cornerRadius = 3.0f;
//    cell.similarBtn.clipsToBounds = YES;
//    cell.similarBtn.layer.borderWidth = 0.5;
    //    [cell.reportBtn setImage:[UIImage imageNamed:@"已上报"] forState:UIControlStateDisabled];
    
    
    return cell;
}
- (void)setModel:(KDCollectCellModel *)model{
    _model = model;
//    self.collectBtn.selected = model.isCollection;
    
    self.titleLb.text = model.title;
    self.comeFromLb.text = model.website_name;
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:model.post_time/ 1000.0];
    self.timeLb.text = [self.fmt stringFromDate:date];
    self.authLb.text = model.author;
    self.featureBtn.selected = (model.emotionType == -1)?YES:NO;
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}
#pragma mark － 事件点击区
/**  收藏按钮被点击了 */
- (IBAction)moveBtnClick:(UIButton *)sender {
    
    //2.选择收藏夹
    if (_delegate && [_delegate respondsToSelector:@selector(subscribCell:moveBtnClick:)]) {
        [_delegate subscribCell:self moveBtnClick:self.moveBtn];
        
    }
    
}
/**  上报按钮被点击了 */
- (IBAction)reportBtnClick:(UIButton *)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(subscribCell:reportBtnClick:)]) {
        [_delegate subscribCell:self reportBtnClick:sender];
    }
}

/**
 *  删除按钮被点击了
 */
- (IBAction)deleteBtnClick:(UIButton *)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(subscribCell:deleteBtnClick:)]) {
        [_delegate subscribCell:self deleteBtnClick:sender];
    }
}




@end
